﻿// Event Listeners - Provided by PSD2HTML
if (window.addEventListener) {
	window.addEventListener("load", switcher, false);
	window.addEventListener("load", closer, false);
	window.addEventListener("load", colors, false);
	window.addEventListener("load", eventHeight, false);
}

// Functions - Provided by PSD2HTML
function switcher(){
	var switchers = document.getElementsByTagName("a");
	if (switchers){
		for (var i = 0; i < switchers.length; i++){
			if (switchers[i].className == "switch")
			{
				switchers[i].onclick = function ()
				{
					if (this.parentNode.parentNode.className.indexOf("collapsed") != -1)
						this.parentNode.parentNode.className = this.parentNode.parentNode.className.replace(new RegExp("collapsed"), "");
					else
						this.parentNode.parentNode.className += " collapsed";
					return false;
				}
			}
		}
	}
}

function closer(){
	var closers = document.getElementsByTagName("a");
	if (closers){
		for (var i = 0; i < closers.length; i++){
			if (closers[i].className == "close")
			{
				if (closers[i].id == "infoClose")
				{
				    closers[i].onclick = function ()
				    {
				        this.parentNode.parentNode.parentNode.parentNode.style.display = "none";
				        isInfoVisible = 0;
				        return false;
				    }
				} else {
				    closers[i].onclick = function ()
				    {
					    this.parentNode.parentNode.style.display = "none";
					    return false;
				    }
				}
			}
		}
	}
}

function colors(){
	var colors = document.getElementsByTagName("ul");
	if (colors){
		for (var i = 0; i < colors.length; i++){
			if (colors[i].className == "colorSelect")
			{
				var colorscells = colors[i].getElementsByTagName("a");
				for (var j = 0; j < colorscells.length; j++){
					colorscells[j].className += " c" + colorscells[j].innerHTML;
				}
			}
		}
	}
}

function eventHeight(){
	var events = document.getElementsByTagName("a");
	if (events){
		for (var i = 0; i < events.length; i++){
			if (events[i].className.indexOf("parts") != -1)
			{
				var eventPart = events[i].className.replace(new RegExp("(.*)?parts(.*)"), "$2");
				events[i].firstChild.style.height = 19 * eventPart + "px";
				events[i].firstChild.style.lineHeight = 19 * eventPart + "px";
				if (events[i].parentNode.className.indexOf("selected") != -1){
					events[i].firstChild.style.height = 19 * eventPart - 4 + "px";
					events[i].firstChild.style.lineHeight = 19 * eventPart - 4 + "px";
				}
			}
		}
	}
}
